package com.bstek.uflo.console.rest;

import com.bstek.uflo.console.rest.model.CompleteTaskInfo;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpEntity;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

/**
 * 重写该类，由于在spring4-web的MappingJacksonHttpMessageConverter类更改为MappingJackson2HttpMessageConverter
 * @Description TODO
 * @Author hans
 * @CreateDate 2020-7-26
 */
public class RestTest {
    public RestTest() {
    }

    public static void main(String[] args) {
        RestTemplate template = new RestTemplate();
        String url = "http://localhost:8080/uflo-test/dorado/uflo/rest/complete/task";
        CompleteTaskInfo info = new CompleteTaskInfo();
        info.setTaskId(60007L);
        Map<String, Object> variables = new HashMap();
        variables.put("aaa", 111);
        variables.put("bbb", "dsfadsaf");
        info.setVariables(variables);
        template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
        template.getMessageConverters().add(new StringHttpMessageConverter());
        HttpEntity<CompleteTaskInfo> entity = new HttpEntity(info);
        template.postForEntity(url, entity, CompleteTaskInfo.class, new Object[0]);
    }
}
